require('../../assets/css/index.less');
require("../../assets/fitness-font/iconfont.css");
require('./sportsCoures.less');


// 引入导航
const { showNav, showTopNav } = require('../../utils/nav');
showNav('sports')
showTopNav('sportscoures')

// 引入axios
const axios = require('../../utils/axios.js');

// 引入window
const { $, g } = require('../../utils/dom')

$(function () {
    /**
     * 获取课程列表
     */
    axios.get('/api/train/courseList').then((res) => {
        if (res.data.errno === 0) {
            let courseList = res.data.data;
            // 删除第一个
            let firstCourse = courseList.shift();

            // 渲染
            g('#newImg').textContent = 'http://fitness.h5.itsource.cn:3701' + firstCourse.imgUrl;
            g('#newTitle').textContent = firstCourse.name;
            g('#newDesc').textContent = firstCourse.desc;
            console.log('res.data :>> ', res.data);


            /**
             * 课程渲染
             */
            let html = '';
            courseList.forEach((v) => {
                html += `
                <a class="couresbox" href='./couresdetail.html#${v.courseId}'>
                    <img src="http://fitness.h5.itsource.cn:3701${v.imgurl}" alt="">
                    <h3 class="suntitle">${v.name}</h3>
                    <p class="text">${v.desc}</p>
                </a>
                `
            })
            // 渲染
            g('.oldcouse').innerHTML += html
        }
    })
})